package lms.utils;


import lms.entity.Book;
import lms.entity.Borrow;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @description:
 * @author: Grape_Pip
 * @time: 2021/06/22
 */
public class BorrowRowMapper implements RowMapper<Borrow> {

    @Override
    public Borrow mapRow(ResultSet resultSet, int i) throws SQLException {
        int boid = resultSet.getInt("boid");
        int bobISBN = resultSet.getInt("bobISBN");
        int borid = resultSet.getInt("borid");
        int bosum = resultSet.getInt("bosum");
        Date botime = resultSet.getDate("botime");
        Date boreturntime = resultSet.getDate("boreturntime");
        int bostatus = resultSet.getInt("bostatus");
        Double bfine = resultSet.getDouble("bfine");
        Borrow borrow = new Borrow();

        borrow.setBorrowId(boid);
        borrow.setBorrowISBN(bobISBN);
        borrow.setBorrowReaderId(borid);
        borrow.setBorrowSum(bosum);
        borrow.setBorrowDate(botime);
        borrow.setReturnDate(boreturntime);
        borrow.setBoStatus(bostatus);
        borrow.setBorrowFine(bfine);

        return borrow;
    }
}
